Imports DowncastSystems.WhereWolf
Imports System.Collections.Generic

Public Class TestProfileProvider
    Implements DowncastSystems.WhereWolf.IProfileProvider

    Private _profiles As New Dictionary(Of String, Profile)

    Public Sub DeleteProfile(ByVal profile As Profile) Implements IProfileProvider.DeleteProfile
        If profile Is Nothing Then
            Throw New ArgumentNullException("profile")
        End If
        If Not Me._profiles.ContainsKey(profile.Name) Then
            Throw New ArgumentException(String.Format("A profile with the name '{0}' doesn't exist.", profile.Name), "profile")
        End If
        Me._profiles.Remove(profile.Name)
    End Sub

    Public Function GetAllProfiles() As System.Collections.Generic.ICollection(Of Profile) Implements IProfileProvider.GetAllProfiles
        Return Me._profiles.Values
    End Function

    Public Function GetProfileByName(ByVal name As String) As Profile Implements IProfileProvider.GetProfileByName
        Dim p As Profile = Nothing
        Me._profiles.TryGetValue(name, p)
        Return p
    End Function

    Public Sub SaveProfile(ByVal profile As Profile) Implements IProfileProvider.SaveProfile
        If profile Is Nothing Then
            Throw New ArgumentNullException("profile")
        End If
        Me._profiles(profile.Name) = profile
    End Sub
End Class
